package com.wildwolf.project.wildwolf.ui;

import java.util.ArrayList;
import java.util.List;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TabWidget;
import android.widget.TextView;

import com.wildwolf.project.wildwolf.R;
import com.wildwolf.project.wildwolf.model.TabWidgetItem;
import com.wildwolf.project.wildwolf.ui.buddy.BuddyActivity;

public class WildwolfActivity extends WildwolfTabHostActivity {
	/*
	 * Widget
	 */
	protected List<TabWidgetItem> tabWidgetItems = null;
	/**
	 * widgetLayoutInflater
	 */
	protected LayoutInflater widgetLayoutInflater = null;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setCurrentTab(0);
	}
	
	@Override
	protected void prepare() {
		super.prepare();
		TabWidgetItem message = new TabWidgetItem(1,getResources().getString(R.string.tabWidget_message),R.drawable.tabwidget_icon_message,R.drawable.widget_tab_item_bg,new Intent(this, WildwolfMessageActivity.class));
		TabWidgetItem friend = new TabWidgetItem(2,getResources().getString(R.string.tabWidget_firend),R.drawable.tabwidget_icon_friend,R.drawable.widget_tab_item_bg,new Intent(this, ContactListActivity.class));
		TabWidgetItem lookfriend = new TabWidgetItem(3,getResources().getString(R.string.tabWidget_lookfriend),R.drawable.tabwidget_icon_lookfriend,R.drawable.widget_tab_item_bg,new Intent(this, BuddyActivity.class));
		TabWidgetItem notice = new TabWidgetItem(4,getResources().getString(R.string.tabWidget_notice),R.drawable.tabwidget_icon_notice,R.drawable.widget_tab_item_bg,new Intent(this, WildwolfMessageActivity.class));
		TabWidgetItem more = new TabWidgetItem(5,getResources().getString(R.string.tabWidget_more),R.drawable.tabwidget_icon_more,R.drawable.widget_tab_item_bg,new Intent(this, WildwolfMessageActivity.class));
		tabWidgetItems = new  ArrayList<TabWidgetItem>();
		tabWidgetItems.add(message);
		tabWidgetItems.add(friend);
		tabWidgetItems.add(lookfriend);
		tabWidgetItems.add(notice);
		tabWidgetItems.add(more);
		// ���÷ָ���
		TabWidget tabWidget = getTabWidget();
		tabWidget.setDividerDrawable(R.drawable.tabwidget_icon_divider);
		widgetLayoutInflater = getLayoutInflater();
	}

	@Override
	protected void setTabItemTextView(TextView textView, int position) {
		textView.setPadding(3, 3, 3, 3);
		textView.setText(tabWidgetItems.get(position).getItemTitle());
		textView.setBackgroundResource(tabWidgetItems.get(position).getItemBackground());
		textView.setCompoundDrawablesWithIntrinsicBounds(0, tabWidgetItems.get(position).getItemIcon(), 0, 0);
	}

	@Override
	protected  int getTabWidgetItemId(int position) {
		return tabWidgetItems.get(position).getTabWidgetItemId();
	}

	@Override
	protected Intent getTabWidgetItemIntent(int position) {
		return tabWidgetItems.get(position).getItemIntent();
	}

	@Override
	protected int getTabWidgetItemCount() {
		return tabWidgetItems.size();
	}
	@Override
	protected View getTop() {
		return null;
	}

}
